package com.longlong.controller.frontDeskApi;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.longlong.entity.RegistrationForm;
import com.longlong.entity.WxGzhUser;
import com.longlong.mapper.RegistrationCompetitionMapper;
import com.longlong.mapper.RegistrationFormMapper;
import com.longlong.mapper.RegistrationRacetrackMapper;
import com.longlong.mapper.WxGzhUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/font")
@Slf4j
public class FMyController {

    @Autowired
    private RegistrationCompetitionMapper registrationCompetitionMapper;
    @Autowired
    private WxGzhUserMapper wxGzhuserMapper;
    @Autowired
    private RegistrationFormMapper registrationFormMapper;

    @Autowired
    private RegistrationRacetrackMapper registrationRacetrackMapper;


    @GetMapping("/getMyCompetitionList")
    public Object getMyCompetitionList(String openId){
        //根据openid获取用户id
        QueryWrapper<WxGzhUser> WGUWrapper = new QueryWrapper<>();
        WGUWrapper.eq("openid_gzh",openId);
        Integer wxGzhUserId = wxGzhuserMapper.selectOne(WGUWrapper).getId();
        QueryWrapper<RegistrationForm> rfWrapper = new QueryWrapper<>();
        rfWrapper.eq("user_id",wxGzhUserId);
        return registrationFormMapper.selectMyCompetitionList(rfWrapper);
    }

    @GetMapping("/getMyCompetitionDetail")
    public Object getMyCompetitionDetail(String id){
        QueryWrapper<RegistrationForm> rFWrapper = new QueryWrapper<>();
        rFWrapper.eq("id",id);
        return registrationFormMapper.selectOne(rFWrapper);
    }

}
















